// 滑动窗口的最大值
var maxValueWindow = function (nums, k) {
    const length = nums.length;
    const queue = [];
    for (let i = 0; i < k; i++) {
        while (queue.length && nums[i] >= nums[queue[queue.length - 1]]) {
            queue.pop();
        }
        queue.push(i);
    }
    let res = [nums[queue[0]]];
    for (let i = k; i < length; i++) {
        while (queue.length && nums[i] >= nums[queue[queue.length - 1]]) {
            queue.pop();
        }
        queue.push(i);
        while (queue[0] <= i - k) {
            q.shift();
        }
        res.push(nums[queue[0]]);
    }
    return res;
}